#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_tranform.h"
#include "../../../../core/shader_widget_panel.h"

#include "../panel.h"
//#include "lib/project_matrix.glsl"
#include "../../../../core/shader_std.h"


layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;
layout(location = 2) in vec2 inNormal;

layout(location = 0) out vec2 gCoords;
layout(location = 1) out flat uint gInstanceIndex;
layout(location = 2) out flat uint gTextureID;


layout(std430, column_major, binding = DEF_BINDING_WIDGET_TextureID) readonly buffer U5_Matrix {
	uint m_TextureArrayID[];
};

layout(push_constant) uniform DRAWPROP_push_constants {
	S_MulTex_ConstPush ConstPush;
};
 
void main(void) {
	gInstanceIndex = gl_InstanceIndex;
	//gInstanceIndex = m_TextureArrayID[gl_InstanceIndex];
	
	mat3x2 mat = m_LP_SD[gl_InstanceIndex];

	vec4 v = f_panel_build(m_Loc, m_Scale, mat, false, inPos, inWeights, gCoords);

	gTextureID = m_TextureArrayID[gl_InstanceIndex + ConstPush.MO_TextureID];

	gl_Position = mat_ProjecView * v;
	gl_PointSize = 4.0;
	
}



